package com.systemic.controller;

import com.systemic.core.ResponseResult;
import com.systemic.service.LikeService;
import com.systemic.vo.LikeVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName: LikeController
 * @Description: 点赞
 * @Author:
 * @CreateTime: 2024-01-21 10:02
 * @Version:
 **/
@RestController
@RequestMapping("/like")
public class LikeController {

    @Resource
    private LikeService likeService;

    /**
     * 点赞
     * @param likeVo
     * @return
     */
    @PostMapping("/create")
    public ResponseResult<String> create(@RequestBody LikeVo likeVo){
        int row = likeService.create(likeVo);
        return row!=0 ? ResponseResult.success("点赞成功") : ResponseResult.failed("点赞失败");
    }

    /**
     * 取消点赞
     * @param likeVo
     * @return
     */
    @PostMapping("/delete")
    public ResponseResult<String> delete(@RequestBody LikeVo likeVo){
        int row = likeService.delete(likeVo);
        return row!=0 ? ResponseResult.success("取消点赞成功") : ResponseResult.failed("取消点赞失败");
    }

}
